package com.lry.web.video.controller;

import com.lry.web.util.Result;
import com.lry.web.util.ResultUtil;
import com.lry.web.video.entity.VideoUpdate;
import com.lry.web.video.service.VideoUpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yaml.snakeyaml.events.Event;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/videoUpdate")
public class VideoUpdateController {
    @Autowired
    VideoUpdateService videoUpdateService;


    @RequestMapping("/deleteByVideoId/{videoId}")
    @ResponseBody
    public Result deleteByVideoId(@PathVariable(value = "videoId") String videoId){
        List<String> list = Arrays.asList(videoId.split(","));
        int i = 0;
        for(String id: list){
            i = videoUpdateService.deleteByVId(id);
        }
        if(i==0){
            return ResultUtil.error(1,"删除失败");
        }else {
            return ResultUtil.success();
        }
    }

    @RequestMapping("/updateByVideoId/{videoId}")
    @ResponseBody
    public Result updateByVideoId(@PathVariable(value = "videoId") String videoId){
        List<String> list = Arrays.asList(videoId.split(","));
        int i = 0;
        for(String id: list){
            i = videoUpdateService.updateDeleted(id);
        }
        if(i==0){
            return ResultUtil.error(1,"开启失败");
        }else {
            return ResultUtil.success();
        }
    }
}
